package com.hp.process;

import com.hp.context.Config;
import org.springframework.context.ApplicationContext;
import org.springframework.web.context.WebApplicationContext;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;

@WebListener
public class Listener implements ServletContextListener {
    @Override
    public void contextInitialized(ServletContextEvent servletContextEvent) {
        System.out.println("系统初始化..................");
       //获取spring容器
        ApplicationContext ac = (ApplicationContext) servletContextEvent.getServletContext().getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE);
        Config.ac=ac;//把容器给 Server
    }

    @Override
    public void contextDestroyed(ServletContextEvent servletContextEvent) {

    }
}
